/*
 * @Author       : tongzonghua
 * @Date         : 2020-10-27 11:19:16
 * @LastEditors  : tongzonghua
 * @LastEditTime : 2020-10-27 12:00:27
 * @Email        : tongzonghua@360.cn
 * @Description  : 
 * @FilePath     : /cli/aframe-boilerplate/components/log.js
 */
AFRAME.registerComponent('log', {
  scheme: {
    event: { type: 'string', default: '' },
    message: { type: "string", default: "hw" }
  },
  init() {
    console.log(8888, this.data.message);
    this.eventHandlerFn = function () {
      console.log('remove==', this.data, this.data.message);
    }
  },
  update() {
    const data = this.data,
      el = this.el;

    if (data.event) {
      el.addEventListener(data.event, function () {
        console.log(111, data.message);
      })
    } else {
      console.log(222, data.message);
    }
  },
  remove() {
    const el = this.el;
    if (this.data.event) {
      console.log('log===', this.data.event, el);
      el.removeEventListener(this.data.event, function () {
        console.log('remove===', this.data);
      })
    }
  }
})